<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
      <title>Search Catalog</title>
        <h:outputStylesheet library="css" name="OnlineLibrary-style.css"/>
    </h:head>
    <body>
           <div  class="container">
    <div class="header">
           <h3 id="main_logo">Online Library</h3>
             <h:panelGroup rendered="#{loginManagerBean.isNotLoggedIn()}">
                 <h:form>
                          <h:outputLabel for="username" value="Username"/> <h:inputText id="username" value="#{loginManagerBean.username}" size="25" /><h:outputLabel for="password" value="password"/> <h:inputSecret value="#{loginManagerBean.password}" size="25"/>
             <h:commandButton value="Login" action="#{loginManagerBean.login()}"/>
             
                
         </h:form>   
         </h:panelGroup>
            <h:panelGroup rendered="#{loginManagerBean.isLoggedIn()}">
                <h:outputText value="Hello, #{loginManagerBean.username}"/>
            </h:panelGroup>
      
    </div>
        
 
         
         <div class="sidebarleft">
             

            <ul class="nav">
            <li><a href="http://localhost:8080/OnlineLibrary/">Home</a></li>
            <li><a href="http://localhost:8080/OnlineLibrary/search.xhtml">Search Catalog</a></li>
            <li><a href="http://localhost:8080/OnlineLibrary/patronsearch.xhtml">Patron Management</a></li>
            <li><h:link outcome="/admin/AddItems.xhtml" rendered="#{loginManagerBean.isAdmin()}">Add New Items</h:link></li>
            <li><h:link outcome="/admin/signup.xhtml" rendered="#{loginManagerBean.isAdmin()}">Add New Member</h:link></li>
            <li><h:link outcome="/admin/periodManagement.xhtml" rendered="#{loginManagerBean.isAdmin()}">Item Period Management</h:link></li>
            <li><h:link outcome="/admin/logs.xhtml" rendered="#{loginManagerBean.isAdmin()}">Activity Log</h:link></li>
            <li><h:link outcome="/browse_catalog.xhtml" rendered="#{loginManagerBean.isLoggedIn()}">Browse Catalog</h:link></li>
            <li><h:form><h:commandLink value="Logout" action="#{loginManagerBean.logout()}" rendered="#{not empty request.remoteUser}" /></h:form></li>
            </ul>
       
        </div><br/>
 
        <div class="content">
            <h3>Find Items</h3>
         <p> Search By title</p>
        <h:form>
            <h:inputText id="searchItem" 
                         
                         value="#{jSFLibraryManagerBean.searchTitle}" 
                         
                         
                         required="true"  />
            <h:commandButton value="Search" 
                             action="#{jSFLibraryManagerBean.findItem}"/>
            
            
            
            
        </h:form> 
         <h:panelGroup rendered="#{jSFLibraryManagerBean.displaySearch}">
        <h:outputText value="Item Found" rendered="#{jSFLibraryManagerBean.displaySearch}"/>
                      
       
        <h:form/>
        <h:dataTable var="item" value="#{jSFLibraryManagerBean.resultItems}"
                    rendered="#{jSFLibraryManagerBean.displaySearch}">
        
            <h:column>
                <f:facet name="header" rendered="#{jSFLibraryManagerBean.displaySearch}">
                    <h:outputText value="ID"/>
                </f:facet>
                <h:outputText value="#{item.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header" rendered="#{jSFLibraryManagerBean.displaySearch}">
                    <h:outputText value="Title"/>
                </f:facet>
                <h:outputText value="#{item.title}"/>
            </h:column>
             <h:column>
                <f:facet name="header" rendered="#{jSFLibraryManagerBean.displaySearch}">
                    <h:outputText value="Author"/>
                </f:facet>
                <h:outputText value="#{item.author}"/>
            </h:column>
             <h:column>
                <f:facet name="header" rendered="#{jSFLibraryManagerBean.displaySearch}">
                    <h:outputText value="Publisher"/>
                </f:facet>
                <h:outputText value="#{item.publisher}"/>
            </h:column>
             <h:column>
                <f:facet name="header" rendered="#{jSFLibraryManagerBean.displaySearch}">
                    <h:outputText value="Year Published"/>
                </f:facet>
                <h:outputText value="#{item.yearPublished}"/>
            </h:column>
             <h:column>
                <f:facet name="header" rendered="#{jSFLibraryManagerBean.displaySearch}">
                    <h:outputText value="Format"/>
                </f:facet>
                <h:outputText value="#{item.format}"/>
            </h:column>
            <h:column>
                <f:facet name="header" rendered="#{jSFLibraryManagerBean.displaySearch}">
                    <h:outputText value="Status"/>
                </f:facet>
                <h:outputText value="#{item.status}"/>
            </h:column>
                    <h:column class="action">
                        <f:facet name="header">
                            <h:outputText value="Action"/>
                        </f:facet>
                           <h:form>
           <h:outputLabel for="patronID" value="Patron ID"/> <h:inputText value="#{jSFLibraryManagerBean.patronID}" required="true" />
           <h:commandButton value="Check-In" action="#{jSFLibraryManagerBean.checkIn(item.id, item.dueDate, item.format)}"/>
           <h:commandButton value="Renew" action="#{jSFLibraryManagerBean.checkOut(item.id, item.title, item.format)}"/>
           <h:commandButton value="Check-Out" action="#{jSFLibraryManagerBean.checkOut(item.id, item.title, item.format)}" />
                 </h:form>
                    </h:column>
        </h:dataTable>
         </h:panelGroup>
       
       
        <h:panelGroup id="itemAction" rendered="#{jSFLibraryManagerBean.displaySearch}">
            
           </h:panelGroup>
        </div>
           </div>
    </body>
</html>
